/**
 * Copyright (C) 2014 xspace app Project.
 */

package cn.xspace.module.other.http.impl;

import com.xspace.android.xafcommon.network.message.AResponseMsg;
import com.xspace.android.xafcommon.network.message.SendRequestListener;

import android.content.Context;

import com.xspace.android.xafcommon.http.resp.BaseGroupRelResp;
import cn.xspace.module.other.http.NetControl;
import cn.xspace.module.other.http.intface.IModifyUserInfo;
import cn.xspace.module.other.http.resp.ModifyUserInfoResp;

/**
 * @version V1.0.0
 * @ClassName: SearchUserImpl
 * @author:mawen
 * @Date：2014-2-25
 * @Description: TODO
 */
public class ModifyUserInfoImpl implements SendRequestListener, IModifyUserInfo {
    private NetControl netControl;
    private Context mContext;

    /**
     * @param
     * @return
     * @throws
     * @Description: TODO
     */
    public ModifyUserInfoImpl(Context context) {
        this.mContext = context;
        netControl = new NetControl(this);
    }

    IModifyInfo callback;

    @Override
    public void modifyUserInfo(String accountID, String logo, String sex,
                               String address, String desc, IModifyInfo callback) {
        this.callback = callback;
        netControl.modifyUserInfo(accountID, logo, sex, address, desc);
    }

    @Override
    public void requestResult(int result, AResponseMsg object) {
        BaseGroupRelResp res = (BaseGroupRelResp) object;
        if ("0".equals(res.code)) {
            callback.callback(res.code, res.desc);
        } else {
            callback.callback(null, null);
        }
    }

    @Override
    public void offline(String msgType) {
    }

    public interface IModifyInfo {
        void callback(String code, String desc);
    }
}
